Option Strict On
Option Explicit On

Imports System

Public Class WrapperMessage
   Private mWrappers As WrapperBase()
   Private mMessage As String
   Private mId As Int32
   Private mLevel As Diagnostics.TraceEventType

   Public Sub New( _
         ByVal message As String, _
         ByVal level As Diagnostics.TraceEventType, _
         ByVal id As Int32, _
         ByVal ParamArray wrappers() As WrapperBase)
      Me.mMessage = message
      Me.mLevel = level
      Me.mWrappers = wrappers
   End Sub

   Public Overrides Function ToString() As String
      Dim s As String = mMessage
      For Each base As MetadataWrapper.WrapperBase In mWrappers
         Console.WriteLine(String.Format("      {0}: {1}", base.GetType.Name, base.IDString))
      Next
      Return s
   End Function

   Public Property Message() As String
      Get
         Return Me.mMessage
      End Get
      Set(ByVal value As String)
         Me.mMessage = value
      End Set
   End Property

   Public Property Id() As Int32
      Get
         Return Me.mId
      End Get
      Set(ByVal value As Int32)
         Me.mId = value
      End Set
   End Property

   Public Property Level() As Diagnostics.TraceEventType
      Get
         Return Me.mLevel
      End Get
      Set(ByVal value As Diagnostics.TraceEventType)
         Me.mLevel = value
      End Set
   End Property

   Public Property Wrappers() As WrapperBase()
      Get
         Return Me.mWrappers
      End Get
      Set(ByVal value As WrapperBase())
         Me.mWrappers = value
      End Set
   End Property

   Public Sub Log(ByVal traceSource As Diagnostics.TraceSource)
      traceSource.TraceData(Me.Level, Me.Id, Guid.NewGuid, Me)
   End Sub
End Class
